﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace ChartEdit
{
    /*
    class ChartElementPart
    {
        public string name; //"Norm" "Hopo" "SP" "Slide" "
        public Image image;
        public Image imageResized;
        public RectangleF boundingBox;
        public PointF offset;
        public Pen sustainPen;

        public void ResizeImage(int width, int height)
        {
            int baseWidth = 240;
            int baseHeight = 385;
            Size size = this.image.Size;

            int newWidth = (int)(((float)width / (float)baseWidth) * boundingBox.Width);
            int newHeight = (int)(((float)height / (float)baseHeight) * boundingBox.Height);

            Bitmap b = new Bitmap(newWidth, newHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage((Image)b);
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.DrawImage(this.image, 0, 0, newWidth, newHeight);
            g.Dispose();

            imageResized = (Image)b;
        }

        public ChartElementPart(ChartElementPart reference, string newName, string newFileName)
        {
            this.name = newName;
            this.image = Image.FromFile(newFileName);

            this.boundingBox = reference.boundingBox;
            this.offset = reference.offset;
            this.sustainPen = reference.sustainPen;
            ResizeImage(240,385);
        }

        public ChartElementPart(string name, string fileName, RectangleF boundingBox, PointF offset, Pen sustainPen)
        {
            this.name = name;
            this.image = Image.FromFile(fileName);
            this.boundingBox = boundingBox;
            this.offset = offset;
            this.sustainPen = sustainPen;
            ResizeImage(240, 385);
        }
    }

    class ChartElement : List<ChartElementPart>
    {
        public string Name;
        public ChartElementPart this[string s]
        {
            get
            {
                foreach (ChartElementPart p in this)
                {
                    if (p.name == s)
                        return p;
                }
                //return default if not found
                return this[0];
            }
        }

        public void Resize(int width, int height)
        {
            for (int i = 0; i < this.Count; i++)
            {
                this[i].ResizeImage(width, height);
            }
        }

        public void Add(ChartElementPart reference, string newName, string newFileName)
        {
            this.Add(new ChartElementPart(reference,newName,newFileName));
        }

        public void Add(string name, string fileName, RectangleF boundingBox, PointF offset, Pen sustainPen)
        {
            this.Add(new ChartElementPart(name, fileName, boundingBox, offset, sustainPen));
        }
        public ChartElement(string Name)
        {
            this.Name = Name;
        }
    }

    class ChartLayout : List<ChartElement>
    {
        public string Name;

        public ChartElement this[string s]
        {
            get
            {
                foreach (ChartElement ce in this)
                {
                    if (ce.Name == s)
                        return ce;
                }
                //return default if not found
                return this[0];
            }
        }
        public ChartLayout(string Name)
        {
            this.Name = Name;
        }
    }

    class ChartLayoutTable : List<ChartLayout>
    {
        public ChartLayout this[string s]
        {
            get
            {
                foreach (ChartLayout cl in this)
                {
                    if (cl.Name == s)
                        return cl;
                }
                //return default if not found
                return this[0];
            }
        }
    }*/
}
